package com.cndw.kungfu.ext;

import com.cndw.kungfu.domain.GoodsMode;
import com.cndw.kungfu.domain.Player;

public class LangUtil {

	public static String getColor(int level) {
		// 颜色(0:白色，1:绿色，2:蓝色，3:紫色，4:橙色，5:红色)
		switch (level) {
		case 0:
			return "#ffffff";
		case 1:
			return "#00ff30";
		case 2:
			return "#06aaff";
		case 3:
			return "#cf28ff";
		case 4:
			return "#ec8f16";
		case 5:
			return "#ff0000";
		}
		return "#c4c2bf";
	}

	public static String makeHtml(int level, String name) {
		return "<font color='" + getColor(level) + "'>" + name + "</font>";
	}

	public static String makeHtml(int level, String name, int num) {
		return "<font color='" + getColor(level) + "'>" + name + (num > 1 ? "x" + num : "") + "</font>";
	}

	public static String numFormat(int indexId) {
		return LangConfigLib.getByIndex("config.comm.num", indexId);
	}

	public static String makeChat(long playerId, GoodsMode goodsMode) {
		StringBuilder sb = new StringBuilder();
		// &%【传说·青铜石剑】,21001,1,108734,9,4&%
		// &%【传说·冷月大剑】,1001,1,20514503,0,4&%
		// &%【传说·冷月大剑】,1001,3,20514503,71,4&%
		sb.append("&%");
		sb.append("【").append(goodsMode.getName()).append("】").append(",");
		sb.append(playerId).append(",");
		sb.append(3).append(",");
		sb.append(goodsMode.getGoodsId()).append(",");
		sb.append(0).append(",");
		sb.append(goodsMode.getColor());
		sb.append("&%");
		return sb.toString();
	}

	public static String makeNameLink(Player player) {
		StringBuilder sb = new StringBuilder();
		sb.append("<a href='event:UserNameLink?playerId=");
		sb.append(player.getPlayerId());
		sb.append("&playName=");
		sb.append(player.getPlayerName());
		sb.append("'>");
		sb.append("<font color='#00ff00'>");
		sb.append(player.getPlayerName());
		sb.append("</font>");
		sb.append("</a>");
		return sb.toString();
	}

}
